package com.keepers.repair.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.EditText;

import com.keepers.repair.R;
import com.keepers.repair.utils.AlertToast;
import com.keepers.repair.view.TitleBar;

/**
 * auth aboom
 * date 2018/11/18
 */
public class EditActivity extends BaseActivity {

    private EditText input;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit);
        TitleBar titleBar = f(R.id.title_bar);
        titleBar.initializeHeader("文字输入");
        titleBar.setRightText("提交", v -> save());
        input = f(R.id.input);
    }

    private void save() {
        String trim = input.getText().toString().trim();
        if (TextUtils.isEmpty(trim)) {
            AlertToast.show("输入内容为空...");
            return;
        }
        Intent intent = new Intent();
        intent.putExtra("edit", trim);
        setResult(Activity.RESULT_OK, intent);
        finish();
    }
}
